flag_verbose: bool,
flag_manifest_path: Option<String>,
flag_no_verify: bool,
+ flag_list: bool,
}
pub const USAGE: &'static str = "
Options:
-h, --help Print this message
- --manifest-path PATH Path to the manifest to compile
+ -l, --list Print files included in a package without making one
--no-verify Don't verify the contents by building them
+ --manifest-path PATH Path to the manifest to compile
-v, --verbose Use verbose output
";
pub fn execute(options: Options, shell: &mut MultiShell) -> CliResult<Option<()>> {
shell.set_verbose(options.flag_verbose);
let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path));
- ops::package(&root, shell, !options.flag_no_verify).map(|_| None).map_err(|err| {
+ ops::package(&root, shell,
+ !options.flag_no_verify,
+ options.flag_list).map(|_| None).map_err(|err| {
CliError::from_boxed(err, 101)
})
}
pub fn package(manifest_path: &Path,
shell: &mut MultiShell,
- verify: bool) -> CargoResult<Path> {
+ verify: bool,
+ list: bool) -> CargoResult<Option<Path>> {
let mut src = try!(PathSource::for_path(&manifest_path.dir_path()));
try!(src.update());
let pkg = try!(src.get_root_package());
+ if list {
+ let root = pkg.get_manifest_path().dir_path();
+ let mut list: Vec<_> = try!(src.list_files(&pkg)).iter().map(|file| {
+ file.path_relative_from(&root).unwrap()
+ }).collect();
+ list.sort();
+ for file in list.iter() {
+ println!("{}", file.display());
+ }
+ return Ok(None)
+ }
+
let filename = format!("package/{}-{}.crate", pkg.get_name(),
pkg.get_version());
let dst = pkg.get_absolute_target_dir().join(filename);
- if dst.exists() { return Ok(dst) }
+ if dst.exists() { return Ok(Some(dst)) }
let mut bomb = Bomb { path: Some(dst.clone()) };
human("failed to verify package tarball")
}))
}
- Ok(bomb.path.take().unwrap())
+ Ok(Some(bomb.path.take().unwrap()))
}
fn tar(pkg: &Package, src: &PathSource, shell: &mut MultiShell,
try!(verify_dependencies(&pkg, ®_id));
// Prepare a tarball
- let tarball = try!(ops::package(manifest_path, shell, verify));
+ let tarball = try!(ops::package(manifest_path, shell, verify, false)).unwrap();
// Upload said tarball to the specified destination
try!(shell.status("Uploading", pkg.get_package_id().to_string()));
compiling = COMPILING,
dir = p.url()).as_slice()));
assert_that(&p.root().join("target/package/foo-0.0.1.crate"), existing_file());
+ assert_that(p.process(cargo_dir().join("cargo")).arg("package").arg("-l"),
+ execs().with_status(0).with_stdout("\
+Cargo.toml
+src[..]main.rs
+"));
assert_that(p.process(cargo_dir().join("cargo")).arg("package"),
execs().with_status(0).with_stdout(""));